package com.hucheng.rest.web;

import com.alibaba.dubbo.config.annotation.Reference;
import com.hucheng.common.exception.EduException;
import com.hucheng.common.page.CommonPager;
import com.hucheng.common.page.PageParameter;
import com.hucheng.common.response.ServiceCoreVO;
import com.hucheng.goods.query.GoodsQuery;
import com.hucheng.goods.service.GoodsService;
import com.hucheng.goods.vo.GoodsVO;
import com.hucheng.rest.base.BaseAction;
import org.springframework.stereotype.Controller;

/**
 * @Author: 凉白开不加冰
 * @Version: 0.0.1V
 * @Date: 2019-07-22
 * @Description: 类描述
 **/
@Controller("goodsAction")
public class GoodsAction  extends BaseAction {

    @Reference
    private GoodsService goodsService;

    /**
     * 商品列表
     *
     * @return
     * @throws EduException
     */
    public ServiceCoreVO listV100() throws EduException {

        String currentPage = getRequestContentValue("currentPage");
        String pageSize = getRequestContentValue("pageSize");

        PageParameter pageParameter = new PageParameter();
        if (currentPage != null && !currentPage.equals("null") &&
                pageSize != null && !pageSize.equals("null")) {
            pageParameter = new PageParameter(Integer.parseInt(currentPage), Integer.parseInt(pageSize));
        }

        GoodsQuery goodsQuery = new GoodsQuery();
        goodsQuery.setPageParameter(pageParameter);
        CommonPager<GoodsVO> commonPager = goodsService.listByPage(goodsQuery);

        return response(commonPager);
    }
}
